<template>
  <div id="sum">
    <h2>测试题</h2>
    <subject @checkSum="isTrue" ref="sub1"></subject>
    <subject @checkSum="isTrue" ref="sub2"></subject>
    <subject @checkSum="isTrue" ref="sub3"></subject>
    <subject @checkSum="isTrue" ref="sub4"></subject>
    <subject @checkSum="isTrue" ref="sub5"></subject>
    <div>
      <flag :flag="flag1"></flag>
      <flag :flag="flag2"></flag>
      <flag :flag="flag3"></flag>
      <flag :flag="flag4"></flag>
      <flag :flag="flag5"></flag>
    </div>
  </div>
</template>

<script>
import Subject from './Subject.vue'
import Flag from './Flag.vue'

export default {
  name: 'RandSum',
  components: {
    Subject,
    Flag
  },
  data(){
    return{
      flag1: null,
      flag2: null,
      flag3: null,
      flag4: null,
      flag5: null
    }
  },
  methods: {
    isTrue(){
      this.flag1 = this.$refs.sub1.isNull() === null ? null : this.$refs.sub1.isFlag;
      this.flag2 = this.$refs.sub2.isNull() === null ? null : this.$refs.sub2.isFlag;
      this.flag3 = this.$refs.sub3.isNull() === null ? null : this.$refs.sub3.isFlag;
      this.flag4 = this.$refs.sub4.isNull() === null ? null : this.$refs.sub4.isFlag;
      this.flag5 = this.$refs.sub5.isNull() === null ? null : this.$refs.sub5.isFlag;
    }
  }
};
</script>

<style>
body {
  background-color: #eee;
}

#sum {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>